class MigrateJobs < ActiveRecord::Migration
  
  class << self
    #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    # Database create/drop methods
    #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    def up
      create_jobs_table
    end

    def down
      drop_jobs_table
    end

    private
      #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      # Table create/drop methods
      #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    
      def create_jobs_table
        create_table_with_history(:jobs, :force => true) do |t|
          t.column("title", :text, :null => false)
          t.column("department", :text, :null => false)
          t.column("supervisor", :text, :null => false)
          t.column("location", :text, :null => false)
          t.column("period_start", :date)
          t.column("period_end", :date, :null => false)
          t.column("description", :text, :null => false)
          t.column("essential_functions", :text, :null => false)
          t.column("non_essential_functions", :text)
          t.column("success_factors", :text)
          t.column("required_list", :text)
          t.column("physical_demands", :text)
          t.column("how_to_respond", :text)
          t.column("notice", :text, :null => false)
          t.column("footer", :text, :null => false)
          t.column("enabled", :boolean, :default => true)
          t.column("updated_by", :integer, :null => false)
          t.column("updated_at", :datetime)
        end

        foreign_key(:jobs, :updated_by, :updaters)
      end

      def drop_jobs_table
        drop_table_with_history(:jobs)
      end
  end #end class block
end
